package controller;

import bean.HelloBean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.UserService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
public class UserController {

    @Resource
    UserService userService;

    @RequestMapping(value = "/user" ,produces = "text/plain;charset=UTF-8")
    public String User(){
        HelloBean helloBean = new HelloBean();
        helloBean.setName("fan范文杰");
        System.out.println(userService.Insert(helloBean));
        return "成功";
    }
    @RequestMapping("/select")
    public void Select(HttpSession httpSession){
        httpSession.setAttribute("name","fan");
        for ( HelloBean helloBean : userService.selectAllUser()){
            System.out.println(helloBean.getName());
        }
    }
}
